﻿using System;
using System.Linq;
//随机生成100个0~1000间的整数，
//使用LINQ语句对这些整数从大到小排序，并求和与平均数。
namespace work4_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int i;
            double sum = 0;
            int[] arr = new int[100];
            Random random = new Random();

            for (i = 0; i < arr.Length; i++)
            {
                arr[i] = random.Next(1,1000);
            }
            int[] arr1 = arr.Select(x => x).OrderByDescending(x => x).ToArray();

            for (i = 0; i < arr.Length; i++)
            {
                Console.WriteLine(arr1[i]);
                sum += arr1[i];
            }
            Console.WriteLine("求和："+ sum);
            Console.WriteLine("平均值："+ sum / 100);
        }
    }
}
